<template>
	<div :style="colorStyle">
		<image :src="items.join_photo" style="width: 100%;" mode="widthFix"></image>
		<view class="titles back_white" @click="showMaoLocation(items)">
			<view class="">
				<view style="display: flex;align-items: center;margin-bottom: 20rpx;">
					<text style="color: #2C2C2C;font-weight: 500;margin-right: 20rpx;">{{items.real_name}}</text>
					<image style="width: 112rpx;" mode="widthFix" src="https://appimg.derunhuatang.com/logo/wechat/jm1.png"  v-if="items.level_type==1"></image>
					<image style="width: 112rpx;" mode="widthFix"  src="https://appimg.derunhuatang.com/logo/wechat/jm2.png"  v-if="items.level_type==2"></image>
					<image style="width: 112rpx;" mode="widthFix"  src="https://appimg.derunhuatang.com/logo/wechat/jm3.png"  v-if="items.level_type==3"></image>
					<image style="width: 132rpx;" mode="widthFix"  src="https://appimg.derunhuatang.com/logo/wechat/jm4.png"  v-if="items.level_type==4"></image>
				</view>
				<view style="display: flex;align-items: center;">
					<image src="https://appimg.derunhuatang.com/logo/wechat/%E4%BD%8D%E7%BD%AE%20(3).png" mode="widthFix" style="width: 20rpx;margin-right: 10rpx;"></image>
					<text>{{items.province+items.city+items.district+items.detail}}</text>
				</view>
			</view>
			<view style="color: #999999; transform: scale(1, 2);transform-origin: -2 -2;">></view>
		</view>
		
		<view class="" style="padding-bottom: 30rpx;">
			<view class="titles">
				<text style="color: #333333;font-weight: 500;">内部展示</text>
				<!-- <view>				
					<text>查看全部 </text>
					<text style="color: #999999; transform: scale(1, 2);transform-origin: -2 -2;"> ></text>
				</view> -->
			</view>
			<view>
				<view style="display: inline-block;width: 300rpx;margin-left: 30rpx;" v-for="item in items.join_info">
					<image style="width: 340rpx;height: 170rpx;border-radius: 10rpx;" :src="item" mode="aspectFit"></image>
				</view>
			</view>
			<recommend :hostProduct="good_list"></recommend>
		</view>
		
		
			
	</div>
</template>

<script>
	import {
		getProductslist
	} from '@/api/store.js';
	import {
		getGoodsDetails
	} from '@/api/agent.js';
	
	import recommend from '@/components/recommend1';
	export default {
		components: {
			recommend
		},
		data() {
			return {
				items:{},good_list:[]
			};
		},
		onLoad(e) {
			let t=this;
			t.getGoodsDetails(e.id);
			getProductslist({cid: 35}).then(res => {
				console.log(res)
				t.good_list = res.data;
			}).catch(err => {
				t.loading = false;
				t.loadTitle = that.$t(`加载更多`);
			});
		},
		
		methods: {
			showMaoLocation(e) {
				let self = this;
				// #ifdef H5
				if (self.$wechat.isWeixin()) {
					self.$wechat.seeLocation({
						latitude: Number(e.latitude),
						longitude: Number(e.longitude)
					}).then(res => {
					})
				} else {
					// #endif	
					uni.openLocation({
						latitude: Number(e.latitude),
						longitude: Number(e.longitude),
						name: e.real_name,
						address: `${e.province}${e.city}${e.district}-${e.detail}`,
						success: function() {
							Number
						}
					});
					// #ifdef H5	
				}
				// #endif
			},
			getGoodsDetails(e) {
				getGoodsDetails({uid:e}).then(res => {
					console.log(res)
					this.items = res.data
				})
			},
			goDetail(item) {
				if (item.activity.length == 0) {
					uni.redirectTo({
						url: "/pages/goods_details/index?id=" + item.id,
					});
					return;
				}
				// 砍价
				if (item.activity && item.activity.type == 2) {
					uni.redirectTo({
						url: `/pages/activity/goods_bargain_details/index?id=${item.activity.id}&bargain=${this.uid}`,
					});
					return;
				}
				// 拼团
				if (item.activity && item.activity.type == 3) {
					uni.redirectTo({
						url: `/pages/activity/goods_combination_details/index?id=${item.activity.id}`,
					});
					return;
				}
				// 秒杀
				if (item.activity && item.activity.type == 1) {
					uni.redirectTo({
						url: `/pages/activity/goods_seckill_details/index?id=${item.activity.id}&time=${item.activity.time}&status=1`,
					});
					return;
				}
			},
			
		},
		onShareAppMessage(res) { //发送给朋友
				let t=this;
				// t.good_list
					return {
						title: t.items.real_name,
						imageUrl:t.items.join_photo,
					}
				},
		onShareTimeline(res) { //分享到朋友圈
			let t=this;
			// t.good_list
				return {
					title: t.items.real_name,
					imageUrl:t.items.join_photo,
				}
		},
	};
</script>

<style lang="scss">
	.back_white{background-color: white;}
	.titles{ 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30rpx;}
	.recommend{background: none;}
	.recommend .title .iconfont{
		font-size: 120rpx;
	}
</style>
